package com.example.weight.navigation;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.example.weight.R;
import com.example.weight.householdWaste.ChoseRoleActivity;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;

public class ShengchanxianchangNavigationActivity extends AppCompatActivity {

    private String name,factory;
    private Button guyefenli,xuning,duifei,shuichuli,chuchou;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shengchanxianchang_nav);

        Intent previousIntent = getIntent();
        name = previousIntent.getStringExtra("name");
        factory = previousIntent.getStringExtra("factory");
        String permissionLevel = previousIntent.getStringExtra("permissionLevel");

        TitleBar titleBar = findViewById(R.id.main_navigation_titleBar);
        titleBar.setOnTitleBarListener(new OnTitleBarListener() {
            @Override
            public void onLeftClick(View v) {
                finish();
            }

            @Override
            public void onTitleClick(View v) {}

            @Override
            public void onRightClick(View v) {}
        });
        guyefenli = findViewById(R.id.guyefenli);
        xuning = findViewById(R.id.xuning);
        duifei = findViewById(R.id.duifei);
        shuichuli = findViewById(R.id.shuichuli);
        chuchou = findViewById(R.id.chuchou);

        initNavEnable(permissionLevel);
    }
    public void turnDuifei(View view) {
        Intent intent =new Intent(ShengchanxianchangNavigationActivity.this, ShengchanxianchangDuifeiNavigationActivity.class);
        intent.putExtra("name", name);
        intent.putExtra("factory", factory);
        startActivity(intent);
    }
    public void turnChuchou(View view) {
        Intent intent =new Intent(ShengchanxianchangNavigationActivity.this, ShengchanxianchangChuchouNavigationActivity.class);
        intent.putExtra("name", name);
        intent.putExtra("factory", factory);
        startActivity(intent);
    }
    public void turnGuyefenli(View view) {
        Intent intent =new Intent(ShengchanxianchangNavigationActivity.this, ShengchanxianchangGuyefenliNavigationActivity.class);
        intent.putExtra("name", name);
        intent.putExtra("factory", factory);
        startActivity(intent);
    }
    public void turnXuning(View view) {
        Intent intent =new Intent(ShengchanxianchangNavigationActivity.this, ShengchanxianchangXuningNavigationActivity.class);
        intent.putExtra("name", name);
        intent.putExtra("factory", factory);
        startActivity(intent);
    }
    public void turnShuichuli(View view) {
        Intent intent =new Intent(ShengchanxianchangNavigationActivity.this, ShengchanxianchangShuichuliNavigationActivity.class);
        intent.putExtra("name", name);
        intent.putExtra("factory", factory);
        startActivity(intent);
    }
    private void initNavEnable(String permissionLevel) {
        if (permissionLevel.equals("0"))
            return;
        guyefenli.setEnabled(false);
        xuning.setEnabled(false);
        duifei.setEnabled(false);
        shuichuli.setEnabled(false);
        chuchou.setEnabled(false);
        if (permissionLevel.contains("生产现场固液分离"))
            guyefenli.setEnabled(true);
        if (permissionLevel.contains("生产现场絮凝"))
            xuning.setEnabled(true);
        if (permissionLevel.contains("生产现场堆肥"))
            duifei.setEnabled(true);
        if (permissionLevel.contains("生产现场水处理"))
            shuichuli.setEnabled(true);
        if (permissionLevel.contains("生产现场除臭"))
            chuchou.setEnabled(true);
    }


}
